from typing import Optional, List, Dict, Any
from datetime import datetime

from pydantic import BaseModel, Field


# 通知基础模型
class NotificationBase(BaseModel):
    title: str
    content: str
    notification_type: str
    priority: str = "normal"
    metadata: Optional[Dict[str, Any]] = None


# 创建通知
class NotificationCreate(NotificationBase):
    recipient_id: int
    sender_id: Optional[int] = None
    project_id: Optional[int] = None


# 更新通知
class NotificationUpdate(BaseModel):
    is_read: Optional[bool] = None
    read_at: Optional[datetime] = None


# API响应中的通知信息
class NotificationResponse(NotificationBase):
    id: int
    recipient_id: int
    sender_id: Optional[int] = None
    project_id: Optional[int] = None
    is_read: bool = False
    read_at: Optional[datetime] = None
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True